﻿using System;
using System.ComponentModel;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using Microsoft.SharePoint;
using Microsoft.SharePoint.WebControls;

namespace SlamCms.SharePoint.Publishing.WebParts
{
    [ToolboxItemAttribute(false)]
    public class CommentsManager : WebPart
    {
        private int _pageSize = 10;
        [Personalizable(PersonalizationScope.Shared),
         WebBrowsable(true),
         Category("Content Display Settings"),
         WebDisplayName("Number of items per page")]
        public int PageSize
        {
            get
            {
                return _pageSize;
            }
            set
            {
                _pageSize = value;
            }
        }

        // Visual Studio might automatically update this path when you change the Visual Web Part project item.
        private const string _ascxPath = @"~/_CONTROLTEMPLATES/SlamCms.SharePoint.Publishing.WebParts/CommentsManager.ascx";

        protected override void CreateChildControls()
        {
            CommentsManagerControl control = Page.LoadControl(_ascxPath) as CommentsManagerControl;
            control.PageSize = PageSize;
            Controls.Add(control);
        }
    }
}
